package com.unis.datapush.controller;

import com.unis.datapush.service.zhlg.ZhHotelDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api(tags = {"ZhHotelDataController"},value = "智慧旅馆",description = "智慧旅馆相关接口说明")
public class ZhHotelDataController {

    @Autowired
    private ZhHotelDataService zhHotelDataService;


    //获取在逃人员预警信息
    @PostMapping("/zhlg/ztryEarly")
    @ApiOperation(value = "智慧旅馆在逃人员信息预警")
    @ApiImplicitParam(name="startTime",value = "查询开始时间")
    public Map<String,Object> getZtryMsg(@RequestBody String startTime){
        Map<String,Object> map = new HashMap<String, Object>();
        try {
            List<Map<String,Object>> res = zhHotelDataService.getZtryMsg(startTime);
            map.put("code","0");
            map.put("data",res);
            map.put("msg","信息获取成功");
        }catch (Exception e){
            e.printStackTrace();
            map.put("code","0");
            map.put("data",null);
            map.put("msg","信息获取失败");

        }
        return map;
    }

    //获取男性频繁入住信息
    @PostMapping("/zhlg/ManLkZdplMsg")
    @ApiOperation(value="男性频繁入住信息")
    public Map<String,Object> getManLkZdplMsg(){
        Map<String,Object> map = new HashMap<String, Object>();
        try {
            List<Map<String,Object>> pl = zhHotelDataService.getManLkZdplMsg();
            map.put("code","0");
            map.put("data",pl);
            map.put("msg","信息获取成功");
        }catch (Exception e){
            e.printStackTrace();
            map.put("code","500");
            map.put("data",null);
            map.put("msg","信息获取失败");
        }
        return map;
    }

    //获取男性频繁入住信息
    @PostMapping("/zhlg/WomanLkZdplMsg")
    @ApiOperation(value="女性频繁入住信息")
    public Map<String,Object> getWomanLkZdplMsg(){
        Map<String,Object> map = new HashMap<String, Object>();
        try {
            List<Map<String,Object>> womanpl = zhHotelDataService.getWomanLkZdplMsg();
            map.put("code","0");
            map.put("data",womanpl);
            map.put("msg","信息获取成功");
        }catch (Exception e){
            e.printStackTrace();
            map.put("code","500");
            map.put("data",null);
            map.put("msg","信息获取失败");
        }
        return map;
    }

}
